#include <iostream>
#define MaxVertexNum 505
#define INFINITY 0x7ffffff
using namespace std;
class Map{
private:
  int Nv;
  int Ne;
  int G[MaxVertexNum][MaxVertexNum];
  int Pnum[MaxVertexNum];
  int origin;
  int terminal;
  int PathNum;
  int MaxPeople;
public:
  Map(){
    PathNum=0;
    MaxPeople=0;
  }
  void MakeMap();
  void ShortestLength();
  void print(){
    if(Nv==0){
        cout<<"0 0"<<endl;
    }else if(origin==terminal){
        cout<<"1 "<<Pnum[origin]<<endl;
    }else{
    cout<<PathNum<<" "<<MaxPeople<<endl;
    } 
  }
};
void Map::MakeMap(){
  cin>>Nv>>Ne>>origin>>terminal;
  for(int i=0;i<Nv;i++){
    cin>>Pnum[i];
  }
  for(int i=0;i<Nv;i++){
    for(int j=0;j<Nv;j++){
      G[i][j]=-1;//Isn't Connected
    }
  }
  int pathorigin;
  int pathterminal;
  int pathlength;
  for(int i=0;i<Ne;i++){
    cin>>pathorigin>>pathterminal>>pathlength;
    G[pathorigin][pathterminal]=pathlength;
    G[pathterminal][pathorigin]=pathlength;
  }
}
void Map::ShortestLength(){
  int NowDistNum[MaxVertexNum];
  int IsKnown[MaxVertexNum]={0};
  int NowPeopleNum[MaxVertexNum]={0};
  int NumberOfPath[MaxVertexNum]={0};
  int V=-1;
  int num=0;
  int dist;
  int min;
  for(int i=0;i<Nv;i++){
    NowDistNum[i]=INFINITY;
    if(i==origin){
      NumberOfPath[i]=1;
      NowDistNum[i]=0;
    }
  }
  while(1){
    min=900000;
    num=0;
    V=-1;
    for(int i=0;i<Nv;i++){
      if(IsKnown[i]==0){
        if(NowDistNum[i]<min){
          V=i;
          min=NowDistNum[i];
          num=NowPeopleNum[i];
        }
        else if(NowDistNum[i]==min&&NowPeopleNum[i]>=num){
          V=i;
          min=NowDistNum[i];
          num=NowPeopleNum[i];
        }
      }
    }
    if(V==-1){
      break;
    }
    IsKnown[V]=1;
    for(int i=0;i<Nv;i++){
      if(!IsKnown[i]){
        if(G[V][i]>=0){
        dist=NowDistNum[V]+G[V][i];
          if(NowDistNum[i]>dist){
            NumberOfPath[i]=NumberOfPath[V];
            NowDistNum[i]=dist;
            NowPeopleNum[i]=NowPeopleNum[V]+Pnum[V];
          }
          else if(NowDistNum[i]==dist){
            NumberOfPath[i]=NumberOfPath[i]+NumberOfPath[V];
            num=NowPeopleNum[V]+Pnum[V];
            if(num>NowPeopleNum[i]){
                NowPeopleNum[i]=num;
            }
          }
        }
        }
      }
    }
    PathNum=NumberOfPath[terminal];
    MaxPeople=NowPeopleNum[terminal]+Pnum[terminal];
 }
int main(){
  Map M;
  M.MakeMap();
  M.ShortestLength();
  M.print();
 }
